package com.mzy.interview

import com.sun.org.apache.bcel.internal.generic.NEW
import java.util.LinkedList

/**
 * @Author: mizy3
 * @Date: 2024/08/25/下午12:11
 * @Description:
 */
class 翻转链表 {


    fun reverseLinkedList(head: ListNode): ListNode? {
        var cur: ListNode? = head
        var prev: ListNode? = null
        // 1 2 3
        while (cur != null) {
            val next = cur.next
            cur.next = prev
            prev = cur
            cur = next
        }

        return prev

    }
}

fun main() {

}